<?php

use Illuminate\Database\Seeder;

class RoleTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $roles = array();

        $role_system = new \App\Tables\Role();
        $role_system->name = 'system';
        $role_system->display_name = '超级管理员';
        $role_system->description = '系统超级管理员，拥有系统所有权限；系统初始化，角色权限配置等';
        array_push($roles, $role_system);

        $role_admin = new \App\Tables\Role();
        $role_admin->name = 'admin';
        $role_admin->display_name = '后台管理员';
        $role_admin->description = '拥有后台大部分权限，仅次于超级管理员';
        array_push($roles, $role_admin);

        $role_web = new \App\Tables\Role();
        $role_web->name = 'web';
        $role_web->display_name = '前台注册用户';
        $role_web->description = '前台注册用户';
        array_push($roles, $role_web);

        $role_web = new \App\Tables\Role();
        $role_web->name = 'agent';
        $role_web->display_name = '代理商';
        $role_web->description = '代理商用户';
        array_push($roles, $role_web);


        foreach ($roles as $role) {
            try {
                $role->save();
            } catch (\Illuminate\Database\QueryException $e) {
                \Illuminate\Support\Facades\Log::info('初始化角色', [$e->getMessage()]);
            }
        }
    }
}
